<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Meetings.aspx.cs" errorPage="~/Error.aspx" Inherits="SecurityLinkUp.Meetings" %>

<%@ Register Assembly="PietschSoft.VE" Namespace="PietschSoft.VE" TagPrefix="PietschSoftVE" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Meetings Admin</title>
</head>
<body>

    <script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

    <script type="text/javascript">  
      //Sys.Application.add_load(GetMeetingMap);    
      var MeetingMap = null;      
      
      function GetMeetingMap()
      {
        MeetingMap = new VEMap('Map'); 
        MeetingMap.SetDashboardSize(VEDashboardSize.Tiny); 
        MeetingMap.LoadMap(new VELatLong(0,0), 0, 'r', false,VEMapMode.Mode2D, false);
        // resize is required in this instance to force the map to size correctly on the page
        MeetingMap.Resize(300,300);
      } 
      
      function FindMeetingLocation (loc)
      {
        try
        {
            var loc = document.getElementById("Location").value;
        
            if (loc != "")
            {
                GetMeetingMap();
                var resultslayer = new VEShapeLayer();
                MeetingMap.AddShapeLayer(resultslayer);
                MeetingMap.Find('', loc, VEFindType.Businesses, resultslayer, 0, 14, true, true, false, true, ProcessMeetingResults);
             }
        }
        catch (e)
        {
            alert(e.message);
        }
      }              
                
      
      function ProcessMeetingResults(layer, findResults, places, hasmore)
      {
            for (resultID in places)
            {                
                var latitude = places[resultID].LatLong.Latitude;
                var longitude = places[resultID].LatLong.Longitude;                
                AddMeetingPushpin(resultID, latitude, longitude, places[resultID].Name, GenerateMeetingDescription(latitude, longitude));
            }
      }
      
      function AddMeetingPushpin(pinId, latitude, longitude, title, details)
      {
        var vell = new VELatLong(latitude, longitude);
        var pp = new VEPushpin(pinId, vell, null , title, details, 'pushpin');
        MeetingMap.AddPushpin(pp);       
      } 
      
      function GenerateMeetingDescription(Lat, Long)
      {
           var link = '<a href=\"javascript:SetMeetingLatLongValues(\'';           
           link +=Lat;
           link +='\', \'';
           link +=Long;
           link +='\')\"> Set this point as location </a>';
           return link;
      }
      
      function SetMeetingLatLongValues(Lat, Long)
      {
         document.getElementById("GeoLat").value = Lat;
         document.getElementById("GeoLong").value = Long;
         document.getElementById("LocationStatusImg").src = "/images/check.png"; 
      }

    </script>

    <form id="Form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table style="width: 660px" cellpadding="5">
                    <tr>
                        <td colspan="2" style="height: 50px" valign="top">
                            Show Meetings For
                            <asp:DropDownList ID="ChapterList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ChapterList_SelectedIndexChanged"
                                Width="245px">
                            </asp:DropDownList>&nbsp;<asp:CheckBox ID="AdminModeChk" runat="server" AutoPostBack="True"
                                OnCheckedChanged="AdminModeChk_CheckedChanged" Text="Set Admin Mode" Visible="False" /><br />
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            Current Meetings<br />
                            <asp:ListBox ID="MeetingsList" runat="server" Height="184px" Width="210px" OnSelectedIndexChanged="MeetingsList_SelectedIndexChanged"
                                AutoPostBack="True"></asp:ListBox><br />
                            <div style="text-align: right">
                                <asp:ImageButton ID="AddMeetingBtn" runat="server" ImageUrl="~/Images/add.png" OnClick="AddMeetingBtn_Click" />
                                <asp:ImageButton ID="DelMeetingBtn" runat="server" ImageUrl="~/Images/delete.png" /><br />
                            </div>
                        </td>
                        <td valign="top" style="width: 726px">
                            <table>
                                <tr>
                                    <td valign="top">
                                        Date/Time</td>
                                    <td style="width: 375px">
                                        <table>
                                            <tr valign="top">
                                                <td>
                                                    <asp:TextBox ID="StartDate" runat="server" Width="75px"></asp:TextBox>&nbsp;<asp:ImageButton
                                                        ID="StartCalendarBtn" runat="server" ImageUrl="~/Images/calendar_btn.png" /><br />
                                                    <asp:TextBox ID="StartTime" runat="server" Width="75px"></asp:TextBox>
                                                    <cc1:MaskedEditExtender ID="StartDateMask" runat="server" TargetControlID="StartDate"
                                                        Mask="99/99/9999" MaskType="Date" ErrorTooltipEnabled="True" />
                                                    <cc1:MaskedEditExtender ID="StartTimeMask" runat="server" TargetControlID="StartTime"
                                                        Mask="99:99:99" MaskType="Time" AcceptAMPM="true" ErrorTooltipEnabled="True" />
                                                    <cc1:CalendarExtender ID="StartCalendar" runat="server" PopupButtonID="StartCalendarBtn"
                                                        TargetControlID="StartDate">
                                                    </cc1:CalendarExtender>
                                                </td>
                                                <td>
                                                    &nbsp;&nbsp; to &nbsp;&nbsp;</td>
                                                <td>
                                                    <asp:TextBox ID="EndDate" runat="server" Width="75px"></asp:TextBox>&nbsp;<asp:ImageButton
                                                        ID="EndCalendarBtn" runat="server" ImageUrl="~/Images/calendar_btn.png" /><br />
                                                    <asp:TextBox ID="EndTime" runat="server" Width="75px"></asp:TextBox>
                                                    <cc1:MaskedEditExtender ID="EndDateMask" runat="server" TargetControlID="EndDate"
                                                        Mask="99/99/9999" MaskType="Date" ErrorTooltipEnabled="True" />
                                                    <cc1:MaskedEditExtender ID="EndTimeMask" runat="server" TargetControlID="EndTime"
                                                        Mask="99:99:99" MaskType="Time" AcceptAMPM="true" ErrorTooltipEnabled="True" />
                                                    <cc1:CalendarExtender ID="EndCalendar" runat="server" PopupButtonID="EndCalendarBtn"
                                                        TargetControlID="EndDate">
                                                    </cc1:CalendarExtender>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td valign="top" rowspan="8">
                                        <PietschSoftVE:Map runat="server" ID="Map" Width="300" Height="300" Zoom="0" Latitude="20.0"
                                            Longitude="10.0" ShowDashboard="false" />
                                        <asp:HiddenField ID="GeoLat" runat="server" />
                                        <asp:HiddenField ID="GeoLong" runat="server" />
                                        <br />
                                        <asp:HyperLink ID="PresentationsLink" runat="server" Visible="False">[PresentationsLink]</asp:HyperLink></td>
                                </tr>
                                <tr>
                                    <td valign="top" style="height: 24px">
                                        Organizer
                                    </td>
                                    <td valign="top" style="width: 375px; height: 24px;">
                                        <asp:DropDownList ID="Organizer" runat="server" Width="200px">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        Title</td>
                                    <td valign="top" style="width: 375px">
                                        <asp:TextBox ID="MeetingTitle" runat="server" Width="298px"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        Description
                                    </td>
                                    <td valign="top" style="width: 375px">
                                        <asp:TextBox ID="Description" runat="server" Rows="5" TextMode="MultiLine" Width="301px"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        Location
                                    </td>
                                    <td valign="top" style="width: 375px">
                                        <asp:TextBox ID="Location" runat="server" Width="260px"></asp:TextBox>
                                        <input type="button" id="FindChapterBtn" value="Find" onclick="FindMeetingLocation()" />
                                        <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="Location"
                                            WatermarkCssClass="WatermarkText" WatermarkText="Address, City, State, Country">
                                        </cc1:TextBoxWatermarkExtender>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        Additional Info</td>
                                    <td style="width: 375px" valign="top">
                                        <asp:TextBox ID="AdditonalInfo" runat="server" Width="303px"></asp:TextBox>
                                        <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server" TargetControlID="AdditonalInfo"
                                            WatermarkCssClass="WatermarkText" WatermarkText="e.g. Room 123, floor 11">
                                        </cc1:TextBoxWatermarkExtender>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top" style="height: 37px">
                                        GeoEncode Location</td>
                                    <td valign="top" style="width: 375px; height: 37px;">
                                        <asp:Image ID="LocationStatusImg" ImageUrl="~/Images/cross.png" runat="server" ImageAlign="Top" />
                                        <div>
                                            <small>[Hover over map pins to set location]</small></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                    </td>
                                    <td align="right" valign="top" style="width: 375px">
                                        <asp:Button ID="SaveMeetingBtn" runat="server" Text="Save Meeting" OnClick="SaveMeetingBtn_Click" /><br />
                                        <asp:Label ID="ErrorMessage" runat="server" CssClass="ErrorMessage"></asp:Label></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <cc1:ModalPopupExtender ID="DeletePopup" runat="server" TargetControlID="DelMeetingBtn"
                    PopupControlID="DeletePopupPanel" BackgroundCssClass="modalBackground" OkControlID="ConfirmDeleteBtn"
                    CancelControlID="CancelBtn" DropShadow="false" />
                <asp:Panel ID="DeletePopupPanel" CssClass="WarningPopup" Style="display: none;" runat="server"
                    Width="396px">
                    <p>
                        Are you sure you want to delete this meeting?</p>
                    <p>
                        Deleting this meeting mean that all the presentations at this meeting will also
                        be deleted</p>
                    <p>
                        Continue to delete anyway?</p>
                    <div style="text-align: center">
                        <asp:Button ID="ConfirmDeleteBtn" runat="server" Text="Delete" OnClick="ConfirmDeleteBtn_Click" />&nbsp;
                        <asp:Button ID="CancelBtn" runat="server" Text="Cancel" />
                    </div>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
